package com.jp.knowledge.dialog;

import android.content.Context;
import android.os.Handler;
import android.view.View;
import android.widget.EditText;

import com.jiayen.util.ToasUtil;
import com.jp.knowledge.R;
import com.jp.knowledge.my.util.MyUtil;

/**
 * Created by 528787067@qq.com on 2017/2/1.
 */

public class ExperienceMergedDialog extends CommDialog {

    private int selectedPosition;
    private int targetPosition;

    private EditText editText;

    public ExperienceMergedDialog(Context context) {
        super(context);
        editText = (EditText) rootView.findViewById(R.id.edit_content);
        editText.setSelectAllOnFocus(true);
        setEditHint("请输入组名");
        setRightClickDismiss(false);
        setCancelable(false);
    }

    @Override
    public void show() {
        setEditText("新建组");
        super.show();
        editText.selectAll();
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                MyUtil.startKeyword(getContext(), editText);
            }
        }, 300);
    }

    @Override
    public void onClick(View view) {
        if(view.getId() == R.id.right_btn && getEditText().trim().length() == 0)
            ToasUtil.toast(getContext(), "请输入有效的组名");
        else
            super.onClick(view);
    }

    public int getSelectedPosition() {
        return selectedPosition;
    }

    public void setSelectedPosition(int selectedPosition) {
        this.selectedPosition = selectedPosition;
    }

    public int getTargetPosition() {
        return targetPosition;
    }

    public void setTargetPosition(int targetPosition) {
        this.targetPosition = targetPosition;
    }
}
